class Solution {
    public:
        int peakIndexInMountainArray(vector<int>& arr) {
            int left = 0, right = arr.size() - 1;
            while (left + 1 < right) {
                int mid = left + (right - left) / 2;
                if(arr[mid]>arr[mid+1]){//下坡
                    right=mid;
                }else{//上坡:arr[mid]<=arr[mid+1]
                    left=mid;
                }
            }
            return right;
        }
    };